package com.mate.cloud.config;

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;

import java.text.MessageFormat;
import java.util.Properties;

/**
 * 属性资源配置获取
 * @author: MI
 * @email: 448341911@qq.com
 * @createTime: 2025/1/28 12:27
 * @updateUser: MI
 * @updateTime: 2025/1/28 12:27
 * @updateRemark: 修改内容
 * @version: v1.0
 */
@Slf4j
public class PropertyConfig extends MessagePropertiesConfig {


    public PropertyConfig() {
        super();
    }


    public static String getProperty(String code,String defaultMessage) {

        log.info("Fetching property for code: {}", code);

        Properties Properties = new MessagePropertiesConfig().loadAndPrintProperties();
        final String message = Properties.getProperty(code);
        if (StringUtils.isBlank(message)) {
            return defaultMessage;
        }
        final String formatMessage = MessageFormat.format(message, defaultMessage);
        log.info("getProperty message: {}", formatMessage);
        return formatMessage;
    }

}
